<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%@page import="iwpl.project.dao.RolesDAO"%>
<%@page import="iwpl.project.entities.Roles"%>
<%@page import="iwpl.project.entities.Accounts"%>
<%@page import="iwpl.project.dao.AccountsDAO"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<center>

	<html>
		<head>
			<base href="<%=basePath%>">
		<script type="text/javascript" src="js/jquery-Source.js"></script>
		<script type="text/javascript" src="js/jquery-Validation.js"></script>
		<link href="css/CommonCSS.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript">
			$(document).ready(function() {
				$("#Department").validate();
			});
		</script>
		
			<title>Reset Password for Account</title>

			<meta http-equiv="pragma" content="no-cache">
			<meta http-equiv="cache-control" content="no-cache">
			<meta http-equiv="expires" content="0">
			<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
			<meta http-equiv="description" content="This is my page">
			<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
			<style type="text/css">
.styleTemplate1 {
	width: 100%;
	height: 142px;
}

.styleTemplate2 {
	width: 300px;
}
</style>
		</head>

		<body>
			<form name="frmUpdateAccount" id="Department" action="./servlet/Control_Account"method="get">
				<table cellpadding="0" cellspacing="0">
					<tr>
						<td>

							
							<%
							Integer id = 0;
							String sAid ="a";
							String sEmployee="a";
							String sRole= "a";
							Integer sEmid = 0;
							String sUsername="a";
							String sDisc="a";
							String spass="";	
							int sActive=0;
							Accounts data=null;
							AccountsDAO acc = new AccountsDAO();
							try
							{
								id = Integer.parseInt(request.getParameter("sid"));
								
								data = acc.findById(id);
								sAid = data.getId().toString();
								sEmid = data.getEmployees().getId();
								sEmployee = data.getEmployees().getFullName();
								sRole = data.getRoles().getRoleName();
								sUsername = data.getUserName();
								sDisc = data.getActive().toString();
								spass =data.getPassword();
								if(data.getActive())
            						{
				            			sActive = 1;
				            		}
				            		else
				            		{
				            			sActive = 0;
				            		}
								
							}
							catch (Exception e) {
								// TODO: handle exception
								
						//endRedirect("../Manage_Roles.jsp?");
								System.out.print(e.getMessage());
							}
								 	
							%>
							<table>
								<tr>
									<td colspan="3" align="center">
										<h1>
											Reset Password for Account
										</h1>
									</td>
								</tr>
								<tr>
									<td>
										EmployeeName:
									</td>
									<td colspan="2">
									<input type="hidden" name="rPass" value="<%=spass%>" />
										<input type="hidden" name="rAid" value="<%=id%>" />
										<input type="hidden" name="rEmid" value="<%=sEmid%>" />
										<input type="hidden" name="action" value="Resetpass" />
										<input type="text" class="required" name="txtEmployeeName" readonly="readonly" value="<%= sUsername %>" />
									</td>
									
								</tr>
								
								<tr>
									<td>
										NewPassword:
									</td>
									<td colspan="2">
										<input type="password" name="txtResetPassword" />
									</td>
								</tr>
								<tr>
									<td>
										<input type="submit" name="btnSave" value="Save" />
									</td>
									<td>
										<input type="button" name="Back" value="Cancel" onClick="self.location='Manage_Account.jsp'"/>
									</td>
								</tr>
								<tr>
									<td colspan="3">
										<%
											if(request.getParameter("message")!=null)
											{
												String a = request.getParameter("message").toString();
												out.print(a);
											}
										 %>
									</td>
								</tr>
							</table>

						</td>
					</tr>
				</table>
			</form>
		</body>
	</html>
</center>